﻿Public Class frmMain

    Dim Path As String = My.Application.Info.DirectoryPath & "\URI.dat"

    Private Sub FileListDataGridView_DragDrop(sender As Object, e As DragEventArgs) Handles FileListDataGridView.DragDrop
        For Each FileName In CType(e.Data.GetData("FileNameW", True), String())
            FileListBindingSource.Insert(0, New GYCrack.FileInfo(FileName))
        Next
    End Sub

    Private Sub FileListDataGridView_DragEnter(sender As Object, e As DragEventArgs) Handles FileListDataGridView.DragEnter
        For Each Format As String In e.Data.GetFormats
            If LCase(Format) = "filedrop" Then
                e.Effect = DragDropEffects.Link
                Exit Sub
            End If
        Next
        e.Effect = DragDropEffects.None
    End Sub

    Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
        Dim Serializer As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
        Dim FS As New IO.FileStream(Path, IO.FileMode.OpenOrCreate, IO.FileAccess.Write)
        Serializer.Serialize(FS, FileListBindingSource.List)
        FS.Close()
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If My.Computer.FileSystem.FileExists(Path) Then
            Dim Serializer As New Runtime.Serialization.Formatters.Binary.BinaryFormatter()
            Dim FS As New IO.FileStream(Path, IO.FileMode.Open, IO.FileAccess.Read)
            Dim InitStructure = Serializer.Deserialize(FS)
            FileListBindingSource.DataSource = InitStructure
            FS.Close()
        End If
    End Sub

End Class